/*
 * @Description: 档案导出相关接口
 * @Author: Rfan
 * @Date: 2022-06-22 11:03:38
 * @LastEditTime: 2023-03-03 09:35:57
 */

import request, { bizZipRequest } from '@/utils/request';
import type { IPageQuery } from '@/interfaces/global';
import { EnumExportBusType } from '@/dictionary/transfer';

/**
 * @description: excel导出
 */
// 查询列表参数类型
export interface IExportListParams {
  archiveTypeId?: number;
  endTime?: string;
  exportType?: number;
  fondsId?: number;
  id?: number;
  name?: string;
  operator?: number;
  operatorTime?: string;
  recordNo?: string;
  startTime?: string;
  status?: number;
  templateId?: number;
}

// 分页查询导出列表
export function fetchExportListByPage(data: IPageQuery<IExportListParams>) {
  return request({
    url: `/archive-export-record/page`,
    method: 'post',
    data
  });
}

// 导出条目信息类型
export interface IExportEntryInfo {
  atCode: number;
  atType: number;
  entryIdList: number[];
  level: number;
  searchCondition: string;
  dbName: string;
}
// 导出规则类型
export interface IExportOriginalRule {
  concatMark: string;
  fieldName: string;
  level: number;
}
// 导出参数类型
export interface ICreateExportParams {
  archiveTypeId: number;
  businessType: EnumExportBusType;
  exportEntryInfo: IExportEntryInfo;
  exportOriginalRule?: IExportOriginalRule;
  exportType: number;
  fondsId: number;
  name?: string;
  templateId?: number;
  lightDiskVolumeId?: number;
}
// 新增导出
export function createExportItem(data: ICreateExportParams) {
  return request({
    url: `/archive-export-record/`,
    method: 'post',
    data
  });
}

// 通过id删除导出记录原文
export function deleteExportOrigin(id: number | string) {
  return request({
    url: `/archive-export-record/original/${id}`,
    method: 'delete'
  });
}

// 删除导出记录
export function deleteExportItem(id: number | string) {
  return request({
    url: `/archive-export-record/${id}`,
    method: 'delete'
  });
}

// ----------------------------------------------------------------
/**
 * @description: 光盘导出
 */
export interface IDiskListParams {
  createTime?: string;
  diskName?: string;
  diskVolume?: string;
  id?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
  volumeType?: number;
  volumeUnit?: number;
}

// 分页查看光盘容量列表
export function fetchDiskTypeList(data: IDiskListParams) {
  return request({
    url: `/light-disk-volume/list`,
    method: 'post',
    data
  });
}

// 分页查看光盘容量列表
export function fetchDiskTypeListByPage(data: IPageQuery<IDiskListParams>) {
  return request({
    url: `/light-disk-volume/page`,
    method: 'post',
    data
  });
}

export interface IDiskParams {
  diskName: string;
  diskVolume: string;
  volumeType: number;
  volumeUnit: number;
}

// 增加光盘容量
export function addDiskType(data: IDiskParams) {
  return request({
    url: `/light-disk-volume/`,
    method: 'post',
    data
  });
}

export interface IEditDiskParams extends Partial<IDiskParams> {
  id: number;
}

// 编辑光盘容量
export function editDiskType(data: IEditDiskParams) {
  return request({
    url: `/light-disk-volume/`,
    method: 'put',
    data
  });
}

// 删除光盘容量
export function deleteDiskType(id: number | string) {
  return request({
    url: `/light-disk-volume/${id}`,
    method: 'delete'
  });
}

// 开始检测任务
export function startDetection(id: number) {
  return request({
    url: `/archive-export-record/start-detection-task/${id}`,
    method: 'get'
  });
}

// 开始打包任务
export function startPackage(id: number) {
  return request({
    url: `/archive-export-record/start-package-task/${id}`,
    method: 'get'
  });
}

// 开始移交任务
export function startTransfer(id: number) {
  return bizZipRequest({
    url: `/archive-export-record/start-transfer-task/${id}`,
    method: 'get'
  });
}
